//
//  LSAttentionTableViewController.m
//  KuaiYi
//
//  Created by 黄金林 on 2016/11/13.
//  Copyright © 2016年 HeiMa. All rights reserved.
//

#import "LSAttentionTableViewController.h"
#import "LSAttentionTableViewCell.h"
#import <YYModel.h>
#import <AFNetworking.h>
#import <MJRefreshNormalHeader.h>
#import <MJRefreshAutoNormalFooter.h>
@interface LSAttentionTableViewController ()<UITableViewDelegate,UITableViewDataSource>
//数据源数组
@property(nonatomic,copy)NSMutableArray *modelArrayM;
@end
@implementation LSAttentionTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView registerClass:[LSAttentionTableViewCell class] forCellReuseIdentifier:@"attentionCell"];
    self.tableView.rowHeight = 60;
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refresh)];
    [self.tableView.mj_header beginRefreshing];
       self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        
            [self.modelArrayM removeAllObjects];
            self.refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@"加载中...."];
            self.refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@"点击或上拉加载更多"];
    }];
    }
//懒加载
- (NSMutableArray *)modelArray{
    if (!_modelArrayM) {
        _modelArrayM = [NSMutableArray array];
    }
    return _modelArrayM;
}

- (void)refresh{
        [self.modelArrayM removeAllObjects];//清除旧数据，每次都加载最新的数据
        self.refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@"加载中...."];
        [self addData];
        self.refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@"松开立即刷新"];
        [self.tableView reloadData];
        [self.refreshControl endRefreshing];
    
}

//加载数据
- (void)addData{
    
    }

#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 8;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    LSAttentionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"attentionCell" forIndexPath:indexPath];
    if (cell == nil) {
        cell = [[LSAttentionTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"attentionCell"];
    }
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss zzz"];
    cell.textLabel.text = [dateFormatter stringFromDate:self.modelArrayM[indexPath.row]];
    return cell;
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
